<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
	<head>
		<meta charset="UTF-8" />
		<title>用户表单</title>
		<div th:replace="/common/common_form_header"></div>
		<style>.row{margin: 0}</style>
		<script type="text/javascript">
			$(document).ready(function() {
				$('#defaultForm').bootstrapValidator({
		            message: 'This value is not valid',
		            feedbackIcons: {
		                valid: 'glyphicon glyphicon-ok',
		                invalid: 'glyphicon glyphicon-remove',
		                validating: 'glyphicon glyphicon-refresh'
		            }, 
		            fields: {
		            	oldPassword: {
		            		 threshold :  4 ,//设置4个字符开始才查询
			                 verbose: false,//多验证的情况下默认第一验证错误，则提示当前错误信息后面的验证不执行
		                    validators: {
		                    	notEmpty: {//检测非空,radio也可用  
		                            message: '还没有填写当前登录密码'  
		                        },
		                        remote: {//将内容发送至指定页面验证，返回验证结果，比如查询用户名是否存在  
		                            url: '/orguser/checkPassword',  
		                            message: '输入的原密码错误',//提示消息
		                            delay: 2000,//每输入一个字符，就发ajax请求，服务器压力还是太大，设置2秒发送一次ajax（默认输入一个字符，提交一次，服务器压力太大）
		                            type: 'POST'  
		                        },
		                    },
		                   
		                } ,
		                newPassword:{
		                	validators:{
		                		notEmpty: {//检测非空,radio也可用  
		                            message: '还没有填写新的密码'  
		                        }
		                	}
		                }
		            }
		        }).on('success.form.bv', function(e) {
		            // Prevent form submission
		            e.preventDefault();

		            // Get the form instance
		            var $form = $(e.target);
					
		            // Get the BootstrapValidator instance
		            var bv = $form.data('bootstrapValidator');

		            // Use Ajax to submit form data
		            $.post($form.attr('action'), $form.serialize(), function(result) {
						window.parent.layer.msg(result.msg);
						closeLayer();
		            }, 'json');
		        }); 
			});
		</script>
	</head>
	<body>
		  <div class="row">
    		<div class="floor-msg">
    			<form id="defaultForm" th:method="post" th:action="@{/system/org/user/updatePassword}">
	    			<div class="form-modal">
						<div class="form-wrap clearfix">
							<div class="col-md-12 col-sm-12 col-xs-12">
								<div class="form-group">
								    <label for="">现有密码</label>
								    <input  type="password" name="oldPassword" id="oldPassword" class="form-control"  >
								</div>
							</div>
							<div class="col-md-12 col-sm-12 col-xs-12">
								<div class="form-group">
								    <label for="">新密码</label>
								    <input  type="password" name="newPassword" id="newPassword" class="form-control" >
								</div>
							</div>
							
							<div class="col-md-6 col-sm-6 col-xs-6">
								<input type="hidden" name="id" id="id" th:value="${user.id}" />
								<input type="hidden" name="userPwd" id="userPwd" th:value="${user.userPwd}" />
								<button type="submit" class="btn btn-primary float-r">保存</button>
							</div>
						 	<div class="col-md-6 col-sm-6 col-xs-6">
								<button type="button" class="btn btn-default" onclick="closeLayer();">取消</button>
							</div>	
							
						</div>
					</div>
				</form>
    		</div>
    	</div> 
    	
	</body>
</html>